<template>
  <el-card>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="科室管理" name="dept" />
      <el-tab-pane label="用户管理" name="employee" />
      <el-tab-pane label="角色管理" name="bg_role" />
      <el-tab-pane label="设备管理" name="bg_device" />
      <el-tab-pane label="操作日志" name="log" />
    </el-tabs>
    <component :is="activeName" :tochild="tochild" :hospital-id="tochild.data.hospitalId" :region-id="tochild.data.regionId" />
  </el-card>
</template>

<script>
import dept from '@/views/back-management/account-set/dept'
import employee from '@/views/back-management/account-set/employee'
import log from '@/views/back-management/account-set/log'
import bg_role from '@/views/back-management/account-set/BG_role'
import bg_device from '@/views/back-management/account-set/BG_device'

export default {
  name: 'BasicManage',
  components: {
    dept,
    employee,
    log,
    bg_role,
    bg_device
  },
  props: {
    tochild: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      activeName: 'dept'
    }
  },

  // created() {
  //   // console.log('来自父组件的数据-', this.tochild)
  //   // 添加刷新监听,刷新后保持tab页选中
  //   window.addEventListener('beforeunload', (e) => this.beforeunloadFn(e))
  //   this.activeName = sessionStorage.getItem('activeName') || this.activeName
  // },
  // beforeDestroy() {
  //   // 卸载监听事件
  //   window.removeEventListener('beforeunload', (e) => this.beforeunloadFn(e))
  //   // 清除sessionStorage
  //   sessionStorage.removeItem('activeName')
  // },
  methods: {
    handleClick(tab, event) {
      // console.log(tab, event)
    }
    // 存储sessionStorage
    // beforeunloadFn(e) {
    //   sessionStorage.setItem('activeName', this.activeName)
    //   // console.log('刷新或关闭')
    // }
  }
}
</script>

  <style>
</style>
